function stockEarning(stockEarning){
	var myChart = echarts.init(document.getElementById('lnsrjg'));
	stockEarning = JSON.parse(stockEarning);
	var list = stockEarning.data;
	var time = [];//时间
	var items =[];
	for (var i = 0; i < list.length; i++) {
		time.push(list[i].year);
		items.push(list[i].items);
	}
	var names = [];//图例
	var earn = [];
	var seriess = [];
	var earning = [];
	var datas = [];
	for (var i = 0; i < items.length; i++) {
		var ss = items[i];
		for (var j = 0; j < ss.length; j++) {
			if(names.indexOf(ss[j].name) == -1){names.push(ss[j].name);}
		}
	}
	for (var k = 0; k < names.length; k++) {
		var data=[]
		var name = names[k];
		var dd =0;
		for (var i = 0; i < items.length; i++) {
			var ss = items[i];
			for (var j = 0; j < ss.length; j++) {
				if(name == ss[j].name){dd = ss[j].revenue}
			}
			/*var nums = unitConvert(dd);
			data.push(nums.num);*/
			data.push(dd);
			dd = 0
		}
		datas.push(data)
	}
	var colorarrays = ["rgb(18, 131, 213)","rgb(45, 202, 207)","rgb(255, 191, 0)","rgb(248, 88, 88)","rgb(225, 105, 203)","rgb(61, 189, 125)","rgb(162, 96, 226)","#357F88","#673509","#310937","#1B9637","#F7393C"];
	var series=[];
	for(var a=0;a<names.length;a++){
		var qqq = {
				"name": names[a],
				"type": "bar",
				"stack": "总量",
				"barMaxWidth": 35,
				"barGap": "10%",
				"itemStyle": {
					"normal": {
						"color":colorarrays[a],
						"label": {
							"show": false,
							"textStyle": {
								"color": "#fff"
							},
							"position": "insideTop",
							formatter: function(p) {
								return p.value > 0 ? (p.value) : '';
							}
						}
					}
				},
				"data": datas[a],
		}
		series.push(qqq)
	}
	
	var xData = function() {
	    var data = time;
	    return data;
	}();

	option = {
	    backgroundColor: "#fff",
	    "title": {
	        "text": "历年收入结构",
	       // "subtext": "BY MICVS",

	        textStyle: {
	            color: '#283b56',
	            fontSize: '18'
	        },
	        subtextStyle: {
	            color: '#90979c',
	            fontSize: '16',

	        },
	    },
	    grid:{
                    left:'20%',
                },
	    "tooltip": {
	        trigger: 'axis',
	        axisPointer: {
	            type: 'cross',
	            label: {
	                backgroundColor: '#283b56'
	            }
	        }
	    },
	    "legend": {
	    	x: '30%',
	        icon: "circle",
	        textStyle: {
	            color: '#90979c',
	        },
	        "data": names //['其他产品', '航空及相关服务及收入', '其他项目']
	    },
	     

	    "calculable": true,
	    "xAxis": [{
	        "type": "category",
	        /*"axisLine": {
	            lineStyle: {
	                color: '#90979c'
	            }
	        },*/
	        "splitLine": {
	            "show": false
	        },
	        "axisTick": {
	            "show": false
	        },
	        "splitArea": {
	            "show": false
	        },
	        "axisLabel": {
	            "interval": 0,

	        },
	        "data": xData,
	    }],
	    "yAxis": [{
	        "type": "value",
	        "splitLine": {
	            "show": false
	        },
	        "axisLine": {
	            lineStyle: {
	                color: '#90979c',
                    width:'2'
	            }
	        },
	        "axisTick": {
	            "show": false
	        },
	        "axisLabel": {
	            "interval": 0,

	        },
	        "splitArea": {
	            "show": false
	        },

	    }],
	    "series": series
	}


	if (option && typeof option === "object") {
	    myChart.setOption(option, true);
	}
	
}


function strNumSize(tempNum) {
    var stringNum = tempNum.toString();
    var index = stringNum.indexOf(".");
    var newNum = stringNum;
    if(index != -1) {
        newNum = stringNum.substring(0, index)
    };
    return newNum.length;
}
function unitConvert(num) {
    var moneyUnits = ["", "万", "亿", "万亿"];
    var dividend = 10000;
    var curentNum = num;
    //转换数字
    var curentUnit = moneyUnits[0];
    //转换单位 
    for(var i = 0; i < 4; i++) {
        curentUnit = moneyUnits[i];
        if(strNumSize(curentNum) < 5) {
            break;
        };
        curentNum = curentNum / dividend;
    };
    var m = {
        num: 0,
        unit: ""
    };
    m.num = curentNum.toFixed(2);
    m.unit = curentUnit;
    return m;
}